home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Trusted Irix /B 4.0.4
/
Trusted-Irix B-4.0.1.iso
/
dist
/
eoe1.idb
/
usr
/
include
/
sys
/
gpib.h.z
/
gpib.h
Wrap
C/C++ Source or Header
|
1992-04-03
|
9KB
|
219 lines
/*
* GPIB software definitions
*/
/* rev-c emulation stuff */
/* board status mask */
#define S_ERR ERR /* error */
#define S_TIMO TIMO /* timeout */
#define S_END END /* EOI or eos */
#define S_SRQI SRQI /* srq asserted */
#define S_RQS RQS /* request service */
#define S_CMPL CMPL /* I/O complete */
#define S_LOK LOK /* local lockout */
#define S_REM REM /* remote */
#define S_CIC CIC /* controller in charge */
#define S_ATN ATN /* attention asserted */
#define S_TACS TACS /* talker active */
#define S_LACS LACS /* listener active */
#define S_DTAS DTAS /* device trigger */
#define S_DCAS DCAS /* device clear */
#define MBITS (S_TIMO|S_END|S_SRQI|S_LOK|S_REM|S_CIC|S_TACS|S_LACS|S_DTAS|S_DCAS)
/* gpib signals */
#define SG_SRQI 8
#define SG_LOK 6
#define SG_REM 5
#define SG_CIC 4
#define SG_TACS 3
#define SG_LACS 2
#define SG_DTAS 1
#define SG_DCAS 0
#define N_SG 9 /* number of signals */
#define NO_SG (int (*)())0 /* no signal */
#define DFLT_SG (int (*)())1 /* default */
struct achain {
long a_buf;
short a_cnt;
};
#define MAXDMA 0x10000 /* most byte we'll transfer */
#define NCHAIN (MAXDMA/NBPP + 2) /* number of achain entries needed */
/* structure exits one per gpib board in system */
struct kboard { /* through b_sig must match struct board in ugpib.h */
word_t b_uflags; /* user flags (see below) */
struct ibregs * b_addr; /* I/O port address */
char b_pad,b_sad; /* primary and secondary gpib address */
char b_eos; /* end-of-string character */
word_t b_tmo; /* timeout value (see below) */
char b_ppe; /* parallel poll enable byte */
char b_irq; /* Interrupt level */
char b_ivec; /* interrupt vector number */
char b_sig; /* UNIX signal to send */
/* remainder is internal structure not accessable by ioctl */
unsigned b_count; /* bytes transfered */
word_t b_error; /* error code */
word_t b_flags; /* internal board flags (see below) */
word_t b_statmem; /* status bits retained between calls */
word_t b_endmem; /* END status bit retained between calls */
int b_ref; /* number of open boards/devices */
char b_brg; /* Bus request/grant */
struct roregs b_ro; /* read only registers */
struct woregs b_wo; /* write only registers */
int (*b_sgnl[N_SG])(); /* gpib signals */
char b_ccc; /* Carry cycle command */
char b_ccf; /* is !=0 if carry cycle used */
char b_imr1sig; /* imr1 bits for enabled signals */
char b_imr2sig; /* imr2 bits for enabled signals */
struct cc_array b_cca; /* carry cycle array */
struct achain b_chain[NCHAIN];
short b_chaincnt;
short b_chainidx;
char b_cmdbuf[20]; /* holds command bytes */
word_t b_lstaddr; /* if != -1, is last addressing on bus */
char b_lstrsv; /* parameter of last ibrsv call */
char b_fdopen; /* if !=0, there are open fd's for board */
word_t b_sigmask; /* mask of signals */
int b_oddc; /* Odd count fudge */
int b_odda; /* Odd address fudge */
struct proc *b_procp; /* copy of u_procp */
struct buf b_bufhdr; /* UNIX I/O buffer */
int b_tid; /* timeout ID */
};
extern struct kboard ibboards[];
extern int nibbrd;
/* board flags (b_flags) */
#define BF_DMATCX (1<<0) /* DMA terminal count interrupt expected */
#define BF_TIMEOUT (1<<1) /* timeout occured */
#define BF_HLDOFF (1<<2) /* handshake heldoff */
#define BF_WANTED (1<<3) /* waiting for exclusive use */
#define BF_BUSY (1<<4) /* exclusive use */
#define BF_STUCKSRQ (1<<5) /* SRQ line is stuck on */
#define BF_IFCRQD (1<<6) /* interface clear needed */
#define BF_AUTOPOLL (1<<7) /* perform automatic serial polls */
#define BF_ONL (1<<8) /* board online */
#define BF_2TICKS (1<<9) /* 2-tick timeout occured */
#define BF_OREM (1<<10) /* old value of REM bit */
#define BF_OLOK (1<<11) /* old value of LOK bit */
#define BF_DMGR (1<<14) /* device management active */
#define SPQCNT 4 /* number of stbs to keep */
struct kdevice {
/* through d_ppe must match struct device in ugpib.h */
word_t d_uflags; /* (see below) */
char d_bna; /* access board number */
char d_pad,d_sad; /* primary and secondary gpib address */
char d_eos; /* end-of-string character */
char d_tmo; /* timeout value */
char d_ppe; /* parallel poll enable byte */
/* internal */
unsigned d_count; /* transfer byte count */
word_t d_flags; /* internal flags */
word_t d_error; /* error number */
char d_spq[SPQCNT];/*serial poll response queue (circular) */
char d_spqidx; /* index into d_spq */
char d_spqcnt; /* number of bytes in queue */
struct gty *d_gtyp; /* pointer to gty structure */
};
/* defines to map the old idevice names to device names to reduce
code changes in the driver. The two structures were identical,
but with different member names, one in gpib.h and one in ugpib.h */
#define id_uflags d_uflags
#define id_bna d_bna
#define id_sad d_sad
#define id_eos d_eos
#define id_tmo d_tmo
#define id_ppe d_ppe
/* same as above, but iboard/board */
#define ib_uflags b_uflags
#define ib_addr b_addr
#define ib_pad b_pad
#define ib_sad b_sad
#define ib_eos b_eos
#define ib_tmo b_tmo
#define ib_ppe b_ppe
#define ib_irq b_irq
#define ib_ivec b_ivec
#define ib_sig b_sig
extern struct kdevice ibdevices[];
extern int nibdev;
/* device user flags (d_uflags) */
/* EOT 000001 /* assert EOI with last byte of each write */
/* HLD 000002 /* holdoff handshake at end of each read */
/* EOSM 000034 /* end-of-string modes */
/* REOS 000004 /* terminate read on eos */
/* XEOS 000010 /* assert EOI with eos byte */
/* BIN 000020 /* eight-bit compare */
/* TDCL 000040 /* terminate I/O on device clear */
/* common board/device flags */
#define CFLAGS (TDCL|EOSM|EOT|HLD)
/* device flags (d_flags) */
#define DF_OPEN (1<<0) /* device is open */
#define DF_CIC (1<<2) /* channel open as CIC */
#define DF_EXCL (1<<5) /* device has exclusive use of board */
#define DF_ESTB (1<<6) /* ESTB error posted */
#define DF_TIK (1<<7) /* RQS timeout tick */
extern unsigned ibglobals;
#define G_DEBUG (1<<0) /* debug print statements */
#define G_NOSPOLL (1<<1) /* no autopoll */
#define G_NOSTAT (1<<2) /* only pass/fail status reporting */
#define G_SPFC (1<<6) /* serial poll/fast cmd timeout change */
extern unsigned int spfc;
/* valid bits for ibwait() */
#define WBITS (TIMO|END|SRQ|LOK|REM|CIC|TACS|LACS|DTAS|DCAS)
/* bits to remember until waited upon */
#define RBITS (DTAS|DCAS)
/* ib_tmvals converts mnemonic to number of ticks */
extern word_t ib_tmvals[];
/* RQS bytes */
#define RQS_ON 0100 /* positive response */
#define TM_WRQS (5*HZ) /* 5 second sleep between checkings for rqs */
/* I/O access modes */
#define USER 0 /* user virtual address */
#define KERN 1 /* kernel virtual address */
#define PHYS 2 /* physical address */
/* GPIB commands */
#define GTL 0001 /* Go To Local */
#define SDC 0004 /* Selected Device Clear */
#define PPC 0005 /* Parallel Poll Configure */
#define GET 0010 /* Group Execute Trigger */
#define TCT 0011 /* Take Control */
#define LLO 0021 /* Local Lock Out */
#define DCL 0024 /* Device Clear */
#define PPU 0025 /* Parallel Poll Unconfigure */
#define SPE 0030 /* Serial Poll Enable */
#define SPD 0031 /* Serial Poll Disable */
#define UNL 0077 /* Unlisten */
#define UNT 0137 /* Untalk */
#define LAD 0040 /* Listen address mask */
#define TAD 0100 /* Talk address mask */
#define Gaddr(p,s) ((p)|((s)<<8)) /* gpib addresses to integer */
#define NOADDR -1 /* impossible gpib address */
#